package ebcs.scan.controller.sys;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import ebcs.app.auto.transmodel.sys.AgencyInforReqModel;
import ebcs.database.bean.sys.PaAgency;
import ebcs.database.service.sys.IAgencyManagerService;
import ebcs.scan.common.consts.AgencyStatus;
import jplat.core.trans.JAppBaseService;
import jplat.core.trans.JAppContext;
import jplat.core.trans.JAppContextFactory;
import jplat.error.exception.JSystemException;
import jplat.error.exception.JTransException;
 

/***
 *  机构管理
 * @author chenzhuo
 * @comment 
 */
@RequestMapping("/sys/")
@Controller
public class AgencyManagerCtrl extends JAppBaseService
{
	@Autowired
	private  IAgencyManagerService agencyService;
	
	private Logger logger = Logger.getLogger(AgencyManagerCtrl.class);
	protected JAppContextFactory serviceFactory = new JAppContextFactory();
	  
	/**
	 * 
	 * @Title: searchAgecny   
	 * @Description: TODO(根据机构名称查询机构信息)   
	 * @return: void      
	 * @throws
	 */
	@RequestMapping("agency/searchAgecny.do")
	public void searchAgecny(HttpServletRequest request, HttpServletResponse response)
			throws JTransException, JSystemException {
		JAppContext context = serviceFactory.buildAppContextWithUser(request, response); // buildAppContextWithUser
		AgencyInforReqModel req = context.obtainReqModel(AgencyInforReqModel.class); 
		PaAgency agency = new PaAgency();
		agency.setName(req.getName());
		agency.setCancelstatus(AgencyStatus.CANCEL_STATE_LIVE.getValue());
		List<PaAgency> agencyList  = this.agencyService.searchAgencyInfor(agency);
 		context.buildAppResponse(agencyList);
	}
}
